package regres;

import stat.StatTables;

/**
 * @author sanbok
 */
public class RegresProportion extends RegresTesters {
	private double a;

	private double deltaA;

	static private String labelName = "q=a*w";

	/*
	 * (non-Javadoc)
	 * 
	 * @see simulationRegress.CalcParam#calculateParameters()
	 */
	public void calculateParameters() {
		double sum = 0;
		double d, tmp;
		double sumW2 = 0, sumWY = 0;
		for (int i = 0; i < factorArray.length; i++) {
			tmp = this.X(factorArray[i]);
			sumW2 += Math.pow(tmp, 2);
			sumWY += tmp * avrgArray[i];
		}
		a = sumWY / sumW2;
		deltaA = (float) (StatTables.student05(n) * Math
				.sqrt(dExpr / sumW2 / n));
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see simulationRegress.CalcParam#f(java.lang.Float)
	 */
	public double f(double arg0) {
		return this.cutF(a * this.X(arg0));
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see simulationRegress.Tester#getLabelName()
	 */
	public String getLabelName() {
		// TODO Auto-generated method stub
		return labelName;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see simulationRegress.CalcParam#k()
	 */
	public int k() {
		return 1;
	}

	public String parametersAsString() {
		return ("a=" + String.valueOf(a));
	}

	public double X(double f) {
		return f;
	}
}
